<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="decorator" content="default"/>
<title>台账管理</title>
<%@include file="/WEB-INF/views/include/treeview.jsp" %>
<style type="text/css">
.ztree {overflow:auto;margin:0;_margin-top:10px;padding:10px 0 0 10px;}
</style>
</head>
<body>
<common:message content="${message}"/>
<div id="content" class="row-fluid">
	<div id="left" class="accordion-group">
		<div class="accordion-heading">
	    	<a class="accordion-toggle">工程列表<i class="icon-refresh pull-right" onclick="refreshTree();"></i></a>
	    </div>
		<div id="ztree" class="ztree"></div>
	</div>
	<div id="openClose" class="close">&nbsp;</div>
	<div id="right">
		<iframe id="opListContent" src="${ctx}/project/tz/list" width="100%" height="91%" frameborder="0"></iframe>
	</div>
</div>
	<script type="text/javascript">
		var setting = {data:{simpleData:{enable:true,idKey:"id",pIdKey:"pId",rootPId:'-1',type: 'type',suoxieSub: 'suoxieSub', suoxiePro: 'suoxiePro'}},
			callback:{onClick:function(event, treeId, treeNode){
					var id = treeNode.id;
					var pid =treeNode.pId;
					var type = treeNode.type;
					var suoxieSub = treeNode.suoxieSub;
					var suoxiePro = treeNode.suoxiePro;
					var src = "${ctx}/project/tz/list";
					if(id!='') {
						if(type=='project') {
							src += '?projectId='+id;
						}else if(type=='subProject') {
							src += '?projectId='+pid+'&subProjectId='+id+'&suoxiePro='+suoxiePro+'&suoxieSub='+suoxieSub;
						}
					}
					$('#opListContent').attr("src",src);
				}
			}
		};
		
		
		function refreshTree(){
			$.getJSON("${ctx}/project/project/subTreeData",function(data){
				$.fn.zTree.init($("#ztree"), setting, data).expandAll(true);
			});
		}
		refreshTree();
		 
		var leftWidth = 180; // 左侧窗口大小
		var htmlObj = $("html"), mainObj = $("#main");
		var frameObj = $("#left, #openClose, #right, #right iframe");
		function wSize(){
			var strs = getWindowSize().toString().split(",");
			htmlObj.css({"overflow-x":"hidden", "overflow-y":"hidden"});
			mainObj.css("width","auto");
			frameObj.height(strs[0] - 5);
			var leftWidth = ($("#left").width() < 0 ? 0 : $("#left").width());
			$("#right").width($("#content").width()- leftWidth - $("#openClose").width() -5);
			$(".ztree").width(leftWidth - 10).height(frameObj.height() - 46);
		}
	</script>
	<script src="${ctxStatic}/common/wsize.min.js" type="text/javascript"></script>
</body>
</html>